import 'reflect-metadata/Reflect.js';
import { Type } from 'class-transformer';
import Moment from 'moment';
import Base from './Base';
import { Compliment } from './ComplimentConfig';
export default class Me extends Base {
  public token = '';
  public name = '';
  public description = '';
  public tags = [];
  public avatar?: string;
  public banner?: string;
  public email = '';
  public type: UserType = UserType.NORMAL;
  public languages: string[] = [];
  public birthday = 0;
  public isFirstLogin = false;
  @Type(() => ShortcutsItem)
  public shortcuts: ShortcutsItem[] = [];
  public followersCount = 0;
  public emailVerification = false;
  public isVerifiedEmailSent = false;
  public viewCount = 0;
  public complimentsCount = 0; // 所有礼物收取的数量
  public videosCount = 0; // 上传的视频的数量
  public audiosCount = 0; // 上传的翻译音频数量
  public playlistsCount = 0;
  public googleId?: string;
  public facebookId?: string;
  public twitterId?: string;
  public windowsId?: string;
  public noPassword = false;
  public compliments?: Compliment[];

  public get memberSinceString(): string {
    return Moment(this.createTime).format('MMM YYYY');
  }
  public get bannerString(): string {
    if (this.banner) {
      return encodeURI(this.banner);
    } else {
      return '';
    }
  }
  public get birthdayString(): string {
    return Moment(this.birthday).format('ll');
  }
}

export enum UserType {
  ADMIN = 0,
  NORMAL = 1,
  TRANSLATOR = 2,
}

export class ShortcutsItem {
  public id = ''; // 内容的ID
  public type: ShortcutsType = ShortcutsType.VIDEO;
  public image = ''; // 视频预览或者头像预览的地址
}
export enum ShortcutsType {
  VIDEO = 0,
  USER = 1,
  PLAYLIST = 2,
  STUDIO = 3,
}
export interface NotificationSettings {
  desktop: boolean;
  newAudios: boolean;
  newVideos: boolean;
  newFollowers: boolean;
  compliments: boolean;
  reactions: boolean;
}
